'use strict';

const { Controller } = require('ee-core');
const Services = require('ee-core/services');

/**
 * relationDb
 * @class
 */
class MysqlMngController extends Controller {
    constructor(ctx) {
        super(ctx);
    }

    /**
     * 查看数据库列表
     * @param connect
     * @returns {Promise<*>}
     */
    async showDataBase(connect) {
        return await Services.get('mysqlMng').showDataBase(connect);
    }

    /**
     * 查看某个数据库下的表、视图、函数
     * @param connect
     * @returns {Promise<*>}
     */
    async showDatabaseTables(connect) {
        return await Services.get('mysqlMng').showDatabaseTables(connect);
    }

    /**
     * 测试数据库连接状态
     */
    async pingConnect(args,event) {
        return  await Services.get('mysqlMng').pingConnect(args);
    }

    /**
     * 查看数据库编码格式
     */
    async charSetNameOptions(args,event) {
        return  await Services.get('mysqlMng').charSetNameOptions(args);
    }
    /**
     *
     * 查看数据库编码格式下属排序编码格式
     */
    async collationNameOptions(args,event) {
        return  await Services.get('mysqlMng').collationNameOptions(args);
    }

    async createDatabase(args,event) {
        return  await Services.get('mysqlMng').createDatabase(args);
    }

    async alterDatabase(args,event) {
        return  await Services.get('mysqlMng').alterDatabase(args);
    }

    async selectTableList(args,event) {
        return  await Services.get('mysqlMng').selectTableList(args);
    }

    async selectTableFields(args,event) {
        return  await Services.get('mysqlMng').selectTableFields(args);
    }

    async selectTableEngines(args,event) {
        return  await Services.get('mysqlMng').selectTableEngines(args);
    }

    async selectTableDataList(args,event) {
        return  await Services.get('mysqlMng').selectTableDataList(args);
    }

    async selectTableDataPageList(args,event) {
        return  await Services.get('mysqlMng').selectTableDataPageList(args);
    }

    async addTableRow(args,event) {
        return  await Services.get('mysqlMng').addTableRow(args);
    }

    async editTableRow(args,event) {
        return  await Services.get('mysqlMng').editTableRow(args);
    }

    async deleteTableRow(args,event) {
        return  await Services.get('mysqlMng').deleteTableRow(args);
    }

    async runConsole(args,event) {
        return  await Services.get('mysqlMng').runConsole(args);
    }

    async saveQueryScript(args,event) {
        return  await Services.get('mysqlMng').saveQueryScript(args);
    }

    async getQueryScript(args,event) {
        return  await Services.get('mysqlMng').getQueryScript(args);
    }

    async deleteQueryScript(args,event) {
        return  await Services.get('mysqlMng').deleteQueryScript(args);
    }

    async getFunctionParamsList(args,event) {
        return  await Services.get('mysqlMng').getFunctionParamsList(args);
    }

    async getQueryViews(args,event) {
        return  await Services.get('mysqlMng').getQueryViews(args);
    }

    async getFunctionList(args,event) {
        return  await Services.get('mysqlMng').getFunctionList(args);
    }

    async getTableIndexList(args,event) {
        return  await Services.get('mysqlMng').getTableIndexList(args);
    }
    async getTableOutsideList(args,event) {
        return  await Services.get('mysqlMng').getTableOutsideList(args);
    }

    async getTableTriggersList(args,event) {
        return  await Services.get('mysqlMng').getTableTriggersList(args);
    }


}

MysqlMngController.toString = () => '[class MysqlMngController]';
module.exports = MysqlMngController;
